Since version 1.40, Visual Studio Code allows fine-grained control over OpenType font features. Windows Terminal v1.11.2921.0 (pre-released in v1.11.2421.0) now allows the same. However, Cascadia Code has gone backwards (from a Haskell perspective). I decided to swap Fira Code for Cascadia Code.
Visual Studio Code
In Visual Studio Code’s settings.json
:
1 2 3 4 5 6 7 8 9 10 |
{ "editor.fontFamily": "Fira Code", "editor.fontLigatures": "'calt', 'cv02', 'ss03', 'ss05', 'zero'", "[haskell]": { "editor.fontLigatures": "'calt', 'cv02', 'cv24', 'ss03', 'ss05', 'ss09', 'zero'" }, "[literate haskell]": { "editor.fontLigatures": "'calt', 'cv02', 'cv24', 'ss03', 'ss05', 'ss09', 'zero'" } } |
cv02
turns on a variant of g
. cv24
turns on a variant of /=
. ss03
turns on a variant of &
. ss05
turns on a variant of @
. ss09
turns on a variant of >>=
(as well as <<=
, ||=
and |=
). zero
turns on a variant of 0
.
Windows Terminal
In Windows Terminal’s settings.json
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
{ "profiles": { "defaults": { "font": { "face": "Fira Code", "size": 12, "features": { "calt": 1, "cv02": 1, "cv24": 1, "ss03": 1, "ss05": 1, "ss09": 1, "zero": 1 } }, }, }, } |
Crayon Syntax Higlighter
Fira Code is provided by the Google Fonts font delivery service. Initially, I used the WordPress add-on ‘Fonts Plugin | Google Fonts Typography’ to load the font without assigning it to an element. However, the font-feature-settings
all appeared to be ignored. The beta version of the online Wakamai Fondue tool indicated that the only layout features used by the current Google Fonts version (version 5.002) were calt
, dnom
, frac
, numr
and wght
. So, I reverted to using a local copy of the font, using the variable font version in WOFF2
format.
Adding the font to my fork of the WordPress plugin Crayon Syntax Highlighter involved creating the following file fira-code.css
in wp-content/uploads/crayon-syntax-highlighter/fonts/
:
1 2 3 4 5 6 7 8 9 10 11 |
@font-face { font-family: 'Fira Code'; src: url('fira-code/FiraCode-VF.woff2') format('woff2-variations'); font-weight: normal; font-style: normal; } .crayon-font-fira-code * { font-family: 'Fira Code', 'Courier New', monospace !important; font-feature-settings: "cv02", "cv24", "ss03", "ss05", "ss09", "zero"; } |
This is my test:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
class Applicative m => Monad m where (>>=) :: forall a b. m a -> (a -> m b) -> m b (>>) :: forall a b. m a -> m b -> m b m >> k = m >>= \_ -> k return :: a -> m a return = pure fail :: String -> m a fail s = errorWithoutStackTrace s -- Tests -- cv02: g -- cv24: /= -- ss03: & -- ss05: @ -- ss09: >>= -- zero: 0 |